package com.nomi.blog.controller;

import com.nomi.blog.service.FollowerService;
import com.nomi.blog.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/follower")
public class FollowerController {
    @Autowired
    private FollowerService followerService;

    /**
     * 获取粉丝列表
     * @param userId
     * @return
     */
    @GetMapping("/list/{userId}")
    public Result getFollowerList(@PathVariable Long userId) {
        return followerService.getFollowerList(userId);
    }

    /**
     * 粉丝记录
     * @param userId
     * @param followerUserId
     * @return
     */
    @PostMapping("/follow/{userId}/{followerUserId}")
    public Result follow(@PathVariable Long userId, @PathVariable Long followerUserId) {
        return followerService.follow(userId, followerUserId);
    }

    /**
     * 取消粉丝记录
     * @param userId
     * @param followerUserId
     * @return
     */
    @PostMapping("/unfollow/{userId}/{followerUserId}")
    public Result unfollow(@PathVariable Long userId, @PathVariable Long followerUserId) {
        return followerService.unfollow(userId, followerUserId);
    }
}